<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .nav {
            position: relative;
            left: 50%;
            top: 100px;
            margin-left: -200px;
        }
        .nav ul {
            overflow: hidden;
            position: absolute;
            z-index: 1;
        }
        li{
            list-style: none;
            float: left;
            width: 83px;
            height: 42px;
            text-align: center;
            line-height: 42px;
        }
        a {
            display: block;
            text-decoration: none;
            width: 100%;
            height: 100%;
        }
        img {
            position: absolute;
            left: 0;
            top: 0;
        }

    </style>
</head>
<body>
    <div class="nav">
        <ul>
            <li><a href="#">你好</a></li>
            <li><a href="#">你好</a></li>
            <li><a href="#">你好</a></li>
            <li><a href="#">你好</a></li>
            <li><a href="#">你好</a></li>
            <li><a href="#">你好</a></li>
        </ul>
        <img src="cloud.gif" alt="">
    </div>
    <script src='../common.js'></script>
    <script>
        //获取元素
        var nav = document.getElementsByClassName('nav')[0];
        var ul = nav.children[0];
        var cloud = nav.children[1];

        //注册事件
        var index = ul.children[0].offsetLeft;
        ul.onmouseover = function(e) {
            animationAll(cloud,{left:e.target.offsetLeft})
        }
        ul.onmouseout = function() {
            animationAll(cloud,{left:index})
        }
        ul.onclick = function(e) {
            index = e.target.offsetLeft;
        }
        
    </script>
</body>
</html>